<!DOCTYPE html>
<html lang=zh>
<head>
  <meta charset="utf-8">
  
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui">
  <meta name="renderer" content="webkit">
  <meta http-equiv="Cache-Control" content="no-transform" />
  <meta http-equiv="Cache-Control" content="no-siteapp" />
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <meta name="format-detection" content="telephone=no,email=no,adress=no">
  <!-- Color theme for statusbar -->
  <meta name="theme-color" content="#000000" />
  <!-- 强制页面在当前窗口以独立页面显示,防止别人在框架里调用页面 -->
  <meta http-equiv="window-target" content="_top" />
  
  
  <title>javafx表格全选 | 猴子的个人博客</title>
  <meta name="description" content="添加 fxml1234567891011&lt;CheckBox fx:id&#x3D;&quot;mSelectAll&quot; layoutX&#x3D;&quot;33.0&quot; layoutY&#x3D;&quot;75.0&quot; onAction&#x3D;&quot;#selectAll&quot;            text&#x3D;&quot;全选&quot; &#x2F;&gt;        &lt;TableVie">
<meta property="og:type" content="article">
<meta property="og:title" content="javafx表格全选">
<meta property="og:url" content="https://chenhouzi.gitee.io/2021/03/31/javafx%E8%A1%A8%E6%A0%BC%E5%85%A8%E9%80%89/index.html">
<meta property="og:site_name" content="xxc的个人博客">
<meta property="og:description" content="添加 fxml1234567891011&lt;CheckBox fx:id&#x3D;&quot;mSelectAll&quot; layoutX&#x3D;&quot;33.0&quot; layoutY&#x3D;&quot;75.0&quot; onAction&#x3D;&quot;#selectAll&quot;            text&#x3D;&quot;全选&quot; &#x2F;&gt;        &lt;TableVie">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2021-03-30T16:48:12.000Z">
<meta property="article:modified_time" content="2021-03-30T16:58:11.865Z">
<meta property="article:author" content="xxc">
<meta property="article:tag" content="javafx">
<meta name="twitter:card" content="summary">
  <!-- Canonical links -->
  <link rel="canonical" href="https://chenhouzi.gitee.io/2021/03/31/javafx%E8%A1%A8%E6%A0%BC%E5%85%A8%E9%80%89/index.html">
  
    <link rel="alternate" href="/atom.xml" title="xxc的个人博客" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png" type="image/x-icon">
  
  
<link rel="stylesheet" href="/css/style.css">

  
  
  
  
<meta name="generator" content="Hexo 5.4.0"></head>


<body class="main-center" itemscope itemtype="http://schema.org/WebPage">
  <header class="header" itemscope itemtype="http://schema.org/WPHeader">
  <div class="slimContent">
    <div class="navbar-header">
      
      
      <div class="profile-block text-center">
        <a id="avatar" href="https://github.com/monkeycxx" target="_blank">
          <img class="img-circle img-rotate" src="/images/avatar.jpg" width="200" height="200">
        </a>
        <h2 id="name" class="hidden-xs hidden-sm">猴子🐵</h2>
        <h3 id="title" class="hidden-xs hidden-sm hidden-md">Web Developer &amp; Designer</h3>
        <small id="location" class="text-muted hidden-xs hidden-sm"><i class="icon icon-map-marker"></i> Jiaxing, China</small>
      </div>
      
      <div class="search" id="search-form-wrap">

    <form class="search-form sidebar-form">
        <div class="input-group">
            <input type="text" class="search-form-input form-control" placeholder="搜索" />
            <span class="input-group-btn">
                <button type="submit" class="search-form-submit btn btn-flat" onclick="return false;"><i class="icon icon-search"></i></button>
            </span>
        </div>
    </form>
    <div class="ins-search">
  <div class="ins-search-mask"></div>
  <div class="ins-search-container">
    <div class="ins-input-wrapper">
      <input type="text" class="ins-search-input" placeholder="想要查找什么..." x-webkit-speech />
      <button type="button" class="close ins-close ins-selectable" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
    </div>
    <div class="ins-section-wrapper">
      <div class="ins-section-container"></div>
    </div>
  </div>
</div>


</div>
      <button class="navbar-toggle collapsed" type="button" data-toggle="collapse" data-target="#main-navbar" aria-controls="main-navbar" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
    </div>
    <nav id="main-navbar" class="collapse navbar-collapse" itemscope itemtype="http://schema.org/SiteNavigationElement" role="navigation">
      <ul class="nav navbar-nav main-nav ">
        
        
        <li class="menu-item menu-item-home">
          <a href="/.">
            
            <i class="icon icon-home-fill"></i>
            
            <span class="menu-title">首页</span>
          </a>
        </li>
        
        
        <li class="menu-item menu-item-archives">
          <a href="/archives">
            
            <i class="icon icon-archives-fill"></i>
            
            <span class="menu-title">归档</span>
          </a>
        </li>
        
        
        <li class="menu-item menu-item-categories">
          <a href="/categories">
            
            <i class="icon icon-folder"></i>
            
            <span class="menu-title">分类</span>
          </a>
        </li>
        
        
        <li class="menu-item menu-item-tags">
          <a href="/tags">
            
            <i class="icon icon-tags"></i>
            
            <span class="menu-title">标签</span>
          </a>
        </li>
        
        
        <li class="menu-item menu-item-repository">
          <a href="/repository">
            
            <i class="icon icon-project"></i>
            
            <span class="menu-title">项目</span>
          </a>
        </li>
        
        
        <li class="menu-item menu-item-books">
          <a href="/books">
            
            <i class="icon icon-book-fill"></i>
            
            <span class="menu-title">书单</span>
          </a>
        </li>
        
        
        <li class="menu-item menu-item-links">
          <a href="/links">
            
            <i class="icon icon-friendship"></i>
            
            <span class="menu-title">友链</span>
          </a>
        </li>
        
        
        <li class="menu-item menu-item-about">
          <a href="/about">
            
            <i class="icon icon-cup-fill"></i>
            
            <span class="menu-title">关于</span>
          </a>
        </li>
        
      </ul>
      
	
    <ul class="social-links">
    	
        <li><a href="https://github.com/monkeycxx" target="_blank" title="Github" data-toggle=tooltip data-placement=top><i class="icon icon-github"></i></a></li>
        
        <li><a href="/atom.xml" target="_blank" title="Rss" data-toggle=tooltip data-placement=top><i class="icon icon-rss"></i></a></li>
        
    </ul>

    </nav>
  </div>
</header>

  
    <aside class="sidebar" itemscope itemtype="http://schema.org/WPSideBar">
  <div class="slimContent">
    
      <div class="widget">
    <h3 class="widget-title">公告</h3>
    <div class="widget-body">
        <div id="board">
            <div class="content">
                <p>欢迎交流与分享经验!</p>
            </div>
        </div>
    </div>
</div>

    
      

    
      
  <div class="widget">
    <h3 class="widget-title">标签</h3>
    <div class="widget-body">
      <ul class="tag-list" itemprop="keywords"><li class="tag-list-item"><a class="tag-list-link" href="/tags/javafx/" rel="tag">javafx</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/unity/" rel="tag">unity</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E4%B8%AA%E4%BA%BA%E8%A7%84%E5%88%92/" rel="tag">个人规划</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E6%B8%B8%E6%88%8F%E5%BC%80%E5%8F%91/" rel="tag">游戏开发</a><span class="tag-list-count">2</span></li></ul>
    </div>
  </div>


    
      
  <div class="widget">
    <h3 class="widget-title">标签云</h3>
    <div class="widget-body tagcloud">
      <a href="/tags/javafx/" style="font-size: 13px;">javafx</a> <a href="/tags/unity/" style="font-size: 14px;">unity</a> <a href="/tags/%E4%B8%AA%E4%BA%BA%E8%A7%84%E5%88%92/" style="font-size: 13px;">个人规划</a> <a href="/tags/%E6%B8%B8%E6%88%8F%E5%BC%80%E5%8F%91/" style="font-size: 14px;">游戏开发</a>
    </div>
  </div>

    
      
  <div class="widget">
    <h3 class="widget-title">归档</h3>
    <div class="widget-body">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2022/12/">十二月 2022</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2021/04/">四月 2021</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2021/03/">三月 2021</a><span class="archive-list-count">3</span></li></ul>
    </div>
  </div>


    
      
  <div class="widget">
    <h3 class="widget-title">最新文章</h3>
    <div class="widget-body">
      <ul class="recent-post-list list-unstyled no-thumbnail">
        
          <li>
            
            <div class="item-inner">
              <p class="item-category">
                
              </p>
              <p class="item-title">
                <a href="/2022/12/11/Homebrew%E8%AF%B4%E6%98%8E/" class="title">Homebrew说明</a>
              </p>
              <p class="item-date">
                <time datetime="2022-12-11T08:39:36.000Z" itemprop="datePublished">2022-12-11</time>
              </p>
            </div>
          </li>
          
          <li>
            
            <div class="item-inner">
              <p class="item-category">
                
              </p>
              <p class="item-title">
                <a href="/2021/04/04/%E6%B8%B8%E6%88%8F%E5%88%B6%E4%BD%9C%E5%B7%A5%E5%85%B7%E9%9B%86%E6%95%B4%E7%90%86/" class="title">游戏制作工具集整理</a>
              </p>
              <p class="item-date">
                <time datetime="2021-04-04T08:54:47.000Z" itemprop="datePublished">2021-04-04</time>
              </p>
            </div>
          </li>
          
          <li>
            
            <div class="item-inner">
              <p class="item-category">
                
              </p>
              <p class="item-title">
                <a href="/2021/03/31/javafx%E8%A1%A8%E6%A0%BC%E5%85%A8%E9%80%89/" class="title">javafx表格全选</a>
              </p>
              <p class="item-date">
                <time datetime="2021-03-30T16:48:12.000Z" itemprop="datePublished">2021-03-31</time>
              </p>
            </div>
          </li>
          
          <li>
            
            <div class="item-inner">
              <p class="item-category">
                
              </p>
              <p class="item-title">
                <a href="/2021/03/30/%E4%B8%AA%E4%BA%BA%E8%A7%84%E5%88%92-%E4%B8%8D%E5%AE%9A%E6%9C%9F%E6%9B%B4%E6%96%B0/" class="title">个人规划-不定期更新</a>
              </p>
              <p class="item-date">
                <time datetime="2021-03-30T09:59:55.000Z" itemprop="datePublished">2021-03-30</time>
              </p>
            </div>
          </li>
          
          <li>
            
            <div class="item-inner">
              <p class="item-category">
                
              </p>
              <p class="item-title">
                <a href="/2021/03/29/hello-world/" class="title">Hello World</a>
              </p>
              <p class="item-date">
                <time datetime="2021-03-28T16:23:29.911Z" itemprop="datePublished">2021-03-29</time>
              </p>
            </div>
          </li>
          
      </ul>
    </div>
  </div>
  

    
  </div>
</aside>

  
  
<main class="main" role="main">
  <div class="content">
  <article id="post-javafx表格全选" class="article article-type-post" itemscope itemtype="http://schema.org/BlogPosting">
    
    <div class="article-header">
      
        
  
    <h1 class="article-title" itemprop="name">
      javafx表格全选
    </h1>
  

      
      <div class="article-meta">
        <span class="article-date">
    <i class="icon icon-calendar-check"></i>
	<a href="/2021/03/31/javafx%E8%A1%A8%E6%A0%BC%E5%85%A8%E9%80%89/" class="article-date">
	  <time datetime="2021-03-30T16:48:12.000Z" itemprop="datePublished">2021-03-31</time>
	</a>
</span>
        
        
  <span class="article-tag">
    <i class="icon icon-tags"></i>
	<a class="article-tag-link-link" href="/tags/javafx/" rel="tag">javafx</a>
  </span>


        

        <span class="post-comment"><i class="icon icon-comment"></i> <a href="/2021/03/31/javafx%E8%A1%A8%E6%A0%BC%E5%85%A8%E9%80%89/#comments" class="article-comment-link">评论</a></span>
        
      </div>
    </div>
    <div class="article-entry marked-body" itemprop="articleBody">
      
        <h3 id="添加-fxml"><a href="#添加-fxml" class="headerlink" title="添加 fxml"></a>添加 fxml</h3><figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">CheckBox</span> <span class="attr">fx:id</span>=<span class="string">&quot;mSelectAll&quot;</span> <span class="attr">layoutX</span>=<span class="string">&quot;33.0&quot;</span> <span class="attr">layoutY</span>=<span class="string">&quot;75.0&quot;</span> <span class="attr">onAction</span>=<span class="string">&quot;#selectAll&quot;</span></span></span><br><span class="line"><span class="tag">            <span class="attr">text</span>=<span class="string">&quot;全选&quot;</span> /&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">TableView</span> <span class="attr">id</span>=<span class="string">&quot;table_view&quot;</span> <span class="attr">fx:id</span>=<span class="string">&quot;mTable&quot;</span> <span class="attr">layoutX</span>=<span class="string">&quot;33.0&quot;</span> <span class="attr">layoutY</span>=<span class="string">&quot;100.0&quot;</span> <span class="attr">prefHeight</span>=<span class="string">&quot;450.0&quot;</span></span></span><br><span class="line"><span class="tag">            <span class="attr">prefWidth</span>=<span class="string">&quot;1100.0&quot;</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">columns</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">TableColumn</span> <span class="attr">fx:id</span>=<span class="string">&quot;mColumnSelect&quot;</span> <span class="attr">prefWidth</span>=<span class="string">&quot;58&quot;</span> <span class="attr">resizable</span>=<span class="string">&quot;false&quot;</span> <span class="attr">sortable</span>=<span class="string">&quot;false&quot;</span></span></span><br><span class="line"><span class="tag">                    <span class="attr">text</span>=<span class="string">&quot;SELECT&quot;</span> <span class="attr">visible</span>=<span class="string">&quot;true&quot;</span> <span class="attr">style</span>=<span class="string">&quot;-fx-alignment:CENTER&quot;</span>&gt;</span><span class="tag">&lt;/<span class="name">TableColumn</span>&gt;</span></span><br><span class="line">                ...</span><br><span class="line">            <span class="tag">&lt;/<span class="name">columns</span>&gt;</span></span><br><span class="line">          ...</span><br><span class="line"><span class="tag">&lt;/<span class="name">TableView</span>&gt;</span></span><br></pre></td></tr></table></figure>

<h3 id="添加Controller"><a href="#添加Controller" class="headerlink" title="添加Controller"></a>添加Controller</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@FXML</span></span><br><span class="line"><span class="keyword">private</span> TableView&lt;DeviceInfo&gt; mTable;</span><br><span class="line"> </span><br><span class="line"><span class="meta">@FXML</span></span><br><span class="line"><span class="keyword">private</span> TableColumn&lt;DeviceInfo, CheckBox&gt; mColumnSelect;</span><br><span class="line"> </span><br><span class="line"><span class="meta">@FXML</span></span><br><span class="line"><span class="keyword">private</span> CheckBox mSelectAll;</span><br><span class="line"> </span><br><span class="line"> </span><br><span class="line"> <span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 对checkbox勾选去勾选处理</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">selectAll</span><span class="params">()</span> </span>&#123;</span><br><span class="line">    ObservableList&lt;DeviceInfo&gt; items = mTable.getItems();</span><br><span class="line">    <span class="keyword">if</span> (mSelectAll.isSelected()) &#123;</span><br><span class="line">        <span class="keyword">for</span> (DeviceInfo deviceInfo : items) &#123;</span><br><span class="line">            deviceInfo.getCb().setSelected(<span class="keyword">true</span>);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">        <span class="keyword">for</span> (DeviceInfo deviceInfo : items) &#123;</span><br><span class="line">            deviceInfo.getCb().setSelected(<span class="keyword">false</span>);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"> </span><br><span class="line"><span class="meta">@FXML</span></span><br><span class="line"><span class="function"><span class="keyword">private</span> <span class="keyword">void</span> <span class="title">initialize</span><span class="params">()</span> </span>&#123;</span><br><span class="line">    ...</span><br><span class="line">    Callback&lt;TableColumn&lt;DeviceInfo, CheckBox&gt;, TableCell&lt;DeviceInfo, CheckBox&gt;&gt;</span><br><span class="line">            selectCellFactory =</span><br><span class="line">            <span class="keyword">new</span> Callback&lt;TableColumn&lt;DeviceInfo, CheckBox&gt;, TableCell&lt;DeviceInfo, CheckBox&gt;&gt;() &#123;</span><br><span class="line">                <span class="meta">@Override</span></span><br><span class="line">                <span class="function"><span class="keyword">public</span> TableCell <span class="title">call</span><span class="params">(TableColumn p)</span> </span>&#123;</span><br><span class="line">                    TableCell cell = <span class="keyword">new</span> TableCell&lt;DeviceInfo, CheckBox&gt;() &#123;</span><br><span class="line">                        <span class="meta">@Override</span></span><br><span class="line">                        <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">updateItem</span><span class="params">(CheckBox item, <span class="keyword">boolean</span> empty)</span> </span>&#123;</span><br><span class="line">                            <span class="keyword">super</span>.updateItem(item, empty);</span><br><span class="line">                            setGraphic(item);</span><br><span class="line">                            <span class="keyword">if</span> (item != <span class="keyword">null</span>) &#123;</span><br><span class="line">                                <span class="comment">//初始化复选框-监听-所有checkbox复选框都勾选则全选框勾选，所有checkbox复选框不勾选则全选框不勾选</span></span><br><span class="line">                                item.selectedProperty()</span><br><span class="line">                                        .addListener(<span class="keyword">new</span> ChangeListener&lt;Boolean&gt;() &#123;</span><br><span class="line">                                            <span class="meta">@Override</span></span><br><span class="line">                                            <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">changed</span><span class="params">(</span></span></span><br><span class="line"><span class="function"><span class="params">                                                    ObservableValue&lt;? extends Boolean&gt; observable,</span></span></span><br><span class="line"><span class="function"><span class="params">                                                    Boolean oldValue, Boolean newValue)</span> </span>&#123;</span><br><span class="line">                                                <span class="keyword">boolean</span> booSelectAll = <span class="keyword">true</span>;</span><br><span class="line">                                                <span class="keyword">for</span> (DeviceInfo deviceInfo : mTable</span><br><span class="line">                                                        .getItems()) &#123;</span><br><span class="line">                                                    <span class="keyword">if</span> (!deviceInfo.getCb().isSelected()) &#123;</span><br><span class="line">                                                        booSelectAll = <span class="keyword">false</span>;</span><br><span class="line">                                                        <span class="keyword">break</span>;</span><br><span class="line">                                                    &#125;</span><br><span class="line">                                                &#125;</span><br><span class="line">                                                mSelectAll.setSelected(booSelectAll);</span><br><span class="line">                                            &#125;</span><br><span class="line">                                        &#125;);</span><br><span class="line">                            &#125;</span><br><span class="line">                        &#125;</span><br><span class="line">                    &#125;;</span><br><span class="line">                    <span class="keyword">return</span> cell;</span><br><span class="line">                &#125;</span><br><span class="line">            &#125;;</span><br><span class="line">    mColumnSelect.setCellFactory(selectCellFactory);</span><br><span class="line">    <span class="comment">// 初始化所有checkbox复选框</span></span><br><span class="line">    mColumnSelect.setCellValueFactory(cellData -&gt; cellData.getValue().getCb().getCheckBox());</span><br><span class="line">    ...</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h3 id="CheckBox封装"><a href="#CheckBox封装" class="headerlink" title="CheckBox封装"></a>CheckBox封装</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Checkbox</span> </span>&#123;</span><br><span class="line">    <span class="keyword">private</span> CheckBox checkbox = <span class="keyword">new</span> CheckBox();</span><br><span class="line"> </span><br><span class="line">    <span class="function"><span class="keyword">public</span> ObservableValue&lt;CheckBox&gt; <span class="title">getCheckBox</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        <span class="keyword">return</span> <span class="keyword">new</span> ObservableValue&lt;CheckBox&gt;() &#123;</span><br><span class="line">            <span class="meta">@Override</span></span><br><span class="line">            <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">addListener</span><span class="params">(ChangeListener&lt;? <span class="keyword">super</span> CheckBox&gt; listener)</span> </span>&#123;</span><br><span class="line"> </span><br><span class="line">            &#125;</span><br><span class="line"> </span><br><span class="line">            <span class="meta">@Override</span></span><br><span class="line">            <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">removeListener</span><span class="params">(ChangeListener&lt;? <span class="keyword">super</span> CheckBox&gt; listener)</span> </span>&#123;</span><br><span class="line"> </span><br><span class="line">            &#125;</span><br><span class="line"> </span><br><span class="line">            <span class="meta">@Override</span></span><br><span class="line">            <span class="function"><span class="keyword">public</span> CheckBox <span class="title">getValue</span><span class="params">()</span> </span>&#123;</span><br><span class="line">                <span class="keyword">return</span> checkbox;</span><br><span class="line">            &#125;</span><br><span class="line"> </span><br><span class="line">            <span class="meta">@Override</span></span><br><span class="line">            <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">addListener</span><span class="params">(InvalidationListener listener)</span> </span>&#123;</span><br><span class="line"> </span><br><span class="line">            &#125;</span><br><span class="line"> </span><br><span class="line">            <span class="meta">@Override</span></span><br><span class="line">            <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">removeListener</span><span class="params">(InvalidationListener listener)</span> </span>&#123;</span><br><span class="line"> </span><br><span class="line">            &#125;</span><br><span class="line">        &#125;;</span><br><span class="line">    &#125;</span><br><span class="line"> </span><br><span class="line">    <span class="function"><span class="keyword">public</span> Boolean <span class="title">isSelected</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        <span class="keyword">return</span> checkbox.isSelected();</span><br><span class="line">    &#125;</span><br><span class="line"> </span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setSelected</span><span class="params">(<span class="keyword">boolean</span> selected)</span> </span>&#123;</span><br><span class="line">        checkbox.setSelected(selected);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h3 id="封装数据"><a href="#封装数据" class="headerlink" title="封装数据"></a>封装数据</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">DeviceInfo</span> </span>&#123;</span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * 是否选中</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="keyword">private</span> Checkbox cb = <span class="keyword">new</span> Checkbox();</span><br><span class="line"> </span><br><span class="line">	...</span><br><span class="line">	</span><br><span class="line">    <span class="function"><span class="keyword">public</span> Checkbox <span class="title">getCb</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        <span class="keyword">return</span> cb;</span><br><span class="line">    &#125;</span><br><span class="line"> </span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setSelected</span><span class="params">(Checkbox cb)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">this</span>.cb = cb;</span><br><span class="line">    &#125;</span><br><span class="line">    </span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>文章为转载记录所用</p>
<p>原文链接：<a target="_blank" rel="noopener" href="https://blog.csdn.net/servermanage/article/details/103395723">https://blog.csdn.net/servermanage/article/details/103395723</a></p>

      
    </div>
    <div class="article-footer">
      <blockquote class="mt-2x">
  <ul class="post-copyright list-unstyled">
    
    <li class="post-copyright-link hidden-xs">
      <strong>本文链接：</strong>
      <a href="https://chenhouzi.gitee.io/2021/03/31/javafx%E8%A1%A8%E6%A0%BC%E5%85%A8%E9%80%89/" title="javafx表格全选" target="_blank" rel="external">https://chenhouzi.gitee.io/2021/03/31/javafx%E8%A1%A8%E6%A0%BC%E5%85%A8%E9%80%89/</a>
    </li>
    
    <li class="post-copyright-license">
      <strong>版权声明： </strong> 本博客所有文章除特别声明外，均采用 <a href="http://creativecommons.org/licenses/by/4.0/deed.zh" target="_blank" rel="external">CC BY 4.0 CN协议</a> 许可协议。转载请注明出处！
    </li>
  </ul>
</blockquote>


<div class="panel panel-default panel-badger">
  <div class="panel-body">
    <figure class="media">
      <div class="media-left">
        <a href="https://github.com/monkeycxx" target="_blank" class="img-burn thumb-sm visible-lg">
          <img src="/images/avatar.jpg" class="img-rounded w-full" alt="">
        </a>
      </div>
      <div class="media-body">
        <h3 class="media-heading"><a href="https://github.com/monkeycxx" target="_blank"><span class="text-dark">猴子🐵</span><small class="ml-1x">Web Developer &amp; Designer</small></a></h3>
        <div>为糊口写代码的靓仔</div>
      </div>
    </figure>
  </div>
</div>


    </div>
  </article>
  
    

  
</div>

  <nav class="bar bar-footer clearfix" data-stick-bottom>
  <div class="bar-inner">
  
  <ul class="pager pull-left">
    
    <li class="prev">
      <a href="/2021/04/04/%E6%B8%B8%E6%88%8F%E5%88%B6%E4%BD%9C%E5%B7%A5%E5%85%B7%E9%9B%86%E6%95%B4%E7%90%86/" title="游戏制作工具集整理"><i class="icon icon-angle-left" aria-hidden="true"></i><span>&nbsp;&nbsp;上一篇</span></a>
    </li>
    
    
    <li class="next">
      <a href="/2021/03/30/%E4%B8%AA%E4%BA%BA%E8%A7%84%E5%88%92-%E4%B8%8D%E5%AE%9A%E6%9C%9F%E6%9B%B4%E6%96%B0/" title="个人规划-不定期更新"><span>下一篇&nbsp;&nbsp;</span><i class="icon icon-angle-right" aria-hidden="true"></i></a>
    </li>
    
    
  </ul>
  
  
  <!-- Button trigger modal -->
  <button type="button" class="btn btn-fancy btn-donate pop-onhover bg-gradient-warning" data-toggle="modal" data-target="#donateModal"><span>赏</span></button>
  <!-- <div class="wave-icon wave-icon-danger btn-donate" data-toggle="modal" data-target="#donateModal">
    <div class="wave-circle"><span class="icon"><i class="icon icon-bill"></i></span></div>
  </div> -->
  
  
  <div class="bar-right">
    
    <div class="share-component" data-sites="weibo,qq,wechat,facebook,twitter" data-mobile-sites="weibo,qq,qzone"></div>
    
  </div>
  </div>
</nav>
  
<!-- Modal -->
<div class="modal modal-center modal-small modal-xs-full fade" id="donateModal" tabindex="-1" role="dialog">
  <div class="modal-dialog" role="document">
    <div class="modal-content donate">
      <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
      <div class="modal-body">
        <div class="donate-box">
          <div class="donate-head">
            <p>感谢您的支持，我会继续努力的!</p>
          </div>
          <div class="tab-content">
            <div role="tabpanel" class="tab-pane fade active in" id="alipay">
              <div class="donate-payimg">
                <img src="/images/donate/alipayimg.png" alt="扫码支持" title="扫一扫" />
              </div>
              <p class="text-muted mv">扫码打赏，你说多少就多少</p>
              <p class="text-grey">打开支付宝扫一扫，即可进行扫码打赏哦</p>
            </div>
            <div role="tabpanel" class="tab-pane fade" id="wechatpay">
              <div class="donate-payimg">
                <img src="/images/donate/wechatpayimg.png" alt="扫码支持" title="扫一扫" />
              </div>
              <p class="text-muted mv">扫码打赏，你说多少就多少</p>
              <p class="text-grey">打开微信扫一扫，即可进行扫码打赏哦</p>
            </div>
          </div>
          <div class="donate-footer">
            <ul class="nav nav-tabs nav-justified" role="tablist">
              <li role="presentation" class="active">
                <a href="#alipay" id="alipay-tab" role="tab" data-toggle="tab" aria-controls="alipay" aria-expanded="true"><i class="icon icon-alipay"></i> 支付宝</a>
              </li>
              <li role="presentation" class="">
                <a href="#wechatpay" role="tab" id="wechatpay-tab" data-toggle="tab" aria-controls="wechatpay" aria-expanded="false"><i class="icon icon-wepay"></i> 微信支付</a>
              </li>
            </ul>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>



</main>

  <footer class="footer" itemscope itemtype="http://schema.org/WPFooter">
	
	
    <ul class="social-links">
    	
        <li><a href="https://github.com/monkeycxx" target="_blank" title="Github" data-toggle=tooltip data-placement=top><i class="icon icon-github"></i></a></li>
        
        <li><a href="/atom.xml" target="_blank" title="Rss" data-toggle=tooltip data-placement=top><i class="icon icon-rss"></i></a></li>
        
    </ul>

    <div class="copyright">
    	
        <div class="publishby">
        	Theme by <a href="https://github.com/cofess" target="_blank"> cofess </a>base on <a href="https://github.com/cofess/hexo-theme-pure" target="_blank">pure</a>.
        </div>
    </div>
</footer>
  <script src="//cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
<script>
window.jQuery || document.write('<script src="js/jquery.min.js"><\/script>')
</script>

<script src="/js/plugin.min.js"></script>


<script src="/js/application.js"></script>


    <script>
(function (window) {
    var INSIGHT_CONFIG = {
        TRANSLATION: {
            POSTS: '文章',
            PAGES: '页面',
            CATEGORIES: '分类',
            TAGS: '标签',
            UNTITLED: '(未命名)',
        },
        ROOT_URL: '/',
        CONTENT_URL: '/content.json',
    };
    window.INSIGHT_CONFIG = INSIGHT_CONFIG;
})(window);
</script>

<script src="/js/insight.js"></script>






   









</body>
</html>